{extend name="base"}
{block name="body"}
<ol class="breadcrumb">
  <li><a href="#">首页</a></li>
  <li><a href="#">商品管理</a></li>
  <li class="active">商品分类</li>
</ol>
<div class="panel panel-default">
  <div class="panel-heading">
    <a href="{:url('addCategory')}" class="btn btn-info">添加分类</a>
  </div>
  <table class="table">
    <colgroup>
      <col style="width: 1%;">
      <col style="width: 5%;">
      <col style="width: 30%;">
      <col style="width: 20%;">
      <col style="width: 10%;">
      <col style="width: 10%;">
    </colgroup>
    <thead>
      <tr align="center">
        <th></th>
        <th>id</th>
        <th>商品分类</th>
        <th>商品分类简称</th>
        <th>是否显示</th>
        <th>操作</th>
      </tr>
    </thead>
    <colgroup>
      <col style="width: 1%;">
      <col style="width: 5%;">
      <col style="width: 30%;">
      <col style="width: 20%;">
      <col style="width: 10%;">
      <col style="width: 10%;">
    </colgroup>
    <tbody>
    {foreach name="category_menu" item="v1"}
      <tr class="form-group" style="height: 30px;">
        <td>
          {if condition="$v1['child'] neq array()"}
          <a href="javascript:;" onclick="tab_toggle({$v1['id']})" style="display: block;">
            <span class="glyphicon glyphicon-plus tabToggleIcon_{$v1['id']}" aria-hidden="true"></span>
          </a>
          {else}
          <a href="javascript:;" onclick="tab_toggle({$v1['id']})" class="tab_jia_{$v1['id']}"
            style="display: block;"><span class="glyphicon glyphicon-minus" aria-hidden="true"></span>
          </a>
          {/if}
        </td>
        <td style="text-align: center;">
          <input type="text" class="form-control" fieldid="{$v1['id']}" fieldname="sort" value="{$v1['id']}" size="1">
        </td>
        <td>
          <input type="text" fieldid="{$v1['id']}" class="form-control" fieldname="category_name" value="{$v1['cname']}">
        </td>
        <td>
          <input type="text" fieldid="{$v1['id']}" class="form-control" fieldname="short_name" value="{$v1['short_name']}">
        </td>
        <td>{$v1['is_visible'] ? '是' : '否'}</td>
        <td><a href="ADMIN_MAIN/Goods/updateGoodsCategory.html?category_id={$v1['id']}"  class="btn btn-default">修改</a>
        <a href="javascript:void(0);"
        onclick="delCategory({$v1['id']})"  class="btn btn-default">删除</a></td>
      </tr>
      {foreach name="v1['child']" item="v2"}
      <tr class="form-group pid_{$v1['id']}" style="height: 30px;display:none;">
        <td>{if condition="$v2['child'] neq array()"}<a
          href="javascript:;"
          onclick="tab_switch({$v2['id']})"
          class="tab_jian_{$v2['id']}"
          style="display: block;"><i class="fa fa-minus-circle"></i></a><a href="javascript:;"
          onclick="tab_switch({$v2['id']})"
          class="tab_jia_{$v2['id']}"
          style="display: none;"><i class="fa fa-plus-circle"></i></a> {/if}
        </td>
        <td style="text-align: center;">
          <input type="text" class="form-control" fieldid="{$v2['id']}" fieldname="sort"  value="{$v2['id']}" size="1"></td>
        <td class="input-group">
          <div class="input-group-addon">|——</div>
          <input type="text" fieldid="{$v2['id']}" class="form-control" fieldname="category_name" value="{$v2['cname']}"></td>
        <td>
          <input type="text" fieldid="{$v2['id']}" class="form-control" fieldname="short_name" value="{$v2['short_name']}">
        </td>
        <td>{$v2['is_visible'] ? '是' : '否'}</td>
        <td><a
        href="ADMIN_MAIN/Goods/updateGoodsCategory.html?category_id={$v2['id']}"  class="btn btn-default">修改</a>
        <a href="javascript:void(0);"
        onclick="delCategory({$v2['id']})"  class="btn btn-default">删除</a></td>
      </tr>
      {foreach name="v2['child']" item="v3"}
      <tr class="form-group pid_{$v2['id']} pid_{$v1['id']}" style="height: 30px;display:none;">
        <td></td>
        <td style="text-align: center;">
          <input type="text" class="form-control" fieldid="{$v3['id']}" fieldname="sort"  value="{$v3['id']}" size="1">
        </td>
        <td class="input-group">
         <div class="input-group-addon">|—————</div>
         <input type="text" class="form-control" fieldid="{$v3['id']}" fieldname="category_name" value="{$v3['cname']}">
        </td>
        <td>
          <input type="text" fieldid="{$v3['id']}" class="form-control" fieldname="short_name" value="{$v3['short_name']}"></td>
        <td>{$v3['is_visible'] ? '是' : '否'}</td>
        <td><a
        href="ADMIN_MAIN/Goods/updateGoodsCategory.html?category_id={$v3['id']}"  class="btn btn-default">修改</a>
        <a href="javascript:void(0);"
        onclick="delCategory({$v3['id']})"  class="btn btn-default">删除</a></td>
      </tr>
      {/foreach} {/foreach} {/foreach}
    </tbody>
  </table>
</div>
<script type="text/javascript">
function tab_toggle(module_id){
  if($(".pid_"+module_id).css('display') != 'none'){
      $(".pid_"+module_id).hide();
      $(".tabToggleIcon_"+module_id).removeClass("glyphicon-minus");
  }else{
      $(".pid_"+module_id).show();
      $(".tabToggleIcon_"+module_id).addClass("glyphicon-minus");
  }
}
</script>
{/block}